﻿using System;
using RpcClient;
using RpcModel;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Service.Interface;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Service
{
        internal class IdentityAppService : IIdentityAppService
        {
                private readonly IIdentityAppCollect _Identity;

                public IdentityAppService (IIdentityAppCollect identity)
                {
                        this._Identity = identity;
                }

                public Guid Add (IdentitySetParam add)
                {
                        IdentityApp app = add.ConvertMap<IdentitySetParam, IdentityApp> ();
                        return this._Identity.Add (app);
                }

                public void Delete (Guid id)
                {
                        IdentityApp app = this._Identity.Get (id);
                        this._Identity.Delete (app);
                }

                public IdentityApp Get (Guid id)
                {
                        return this._Identity.Get (id);
                }

                public IdentityApp[] Query (IdentityQueryParam query, IBasicPage paging, out long count)
                {
                        return this._Identity.Query (query, paging, out count);
                }
                public void SetIsEnable (Guid id, bool isEnable)
                {
                        IdentityApp app = this._Identity.Get (id);
                        this._Identity.SetIsEnable (app, isEnable);
                }
                public void Set (Guid id, IdentitySetParam param)
                {
                        IdentityApp app = this._Identity.Get (id);
                        this._Identity.Set (app, param);
                }
        }
}
